import data_control from "../libs/data_control";

const {ccclass, property} = cc._decorator;

@ccclass
export default class cloudFloat extends cc.Component {

    @property({tooltip:"最短时间"})
    minTime:number = 1;

    @property({tooltip:"最长时间"})
    maxTime:number = 3;

    @property({tooltip:"对于初始位置Y轴的最短目标距离"})
    targetYMinDistance:number = 20;

    @property({tooltip:"对于初始位置Y轴的最长目标距离"})
    targetYMaxDistance:number = 50;

    initY:number = 0;

    start(){
        this.initY = this.node.y;
        this.cloudAni();
    }

    cloudAni(){
        let randTime:number = data_control.getRandNumberOfArrayTwo([this.minTime,this.maxTime]);
        let targetY:number = this.initY + data_control.getRandNumberOfArrayTwo([this.targetYMinDistance,this.targetYMaxDistance]);
        cc.tween(this.node).to(randTime / 2,{y:targetY}).delay(0.1).to(randTime / 2,{y:this.initY}).delay(0.1).call(()=>{
            this.cloudAni();
        }).start();
    }

}
